namespace MvcEnrollment.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class StuCascadePayID : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Payment", "courseID", "dbo.Course");
            DropForeignKey("dbo.Student", "courseId", "dbo.Course");
            DropForeignKey("dbo.Student", "paymentId", "dbo.Payment");
            DropIndex("dbo.Payment", new[] { "courseID" });
            DropIndex("dbo.Student", new[] { "courseId" });
            DropIndex("dbo.Student", new[] { "paymentId" });
            AddColumn("dbo.Payment", "CreatedBy", c => c.String());
            AddColumn("dbo.Payment", "CreatedDate", c => c.DateTime());
            AddColumn("dbo.Student", "CreatedBy", c => c.String());
            AddColumn("dbo.Student", "CreatedDate", c => c.DateTime());
            AddColumn("dbo.Transaction", "CreatedBy", c => c.String());
            AddColumn("dbo.Transaction", "CreatedDate", c => c.DateTime());
            AlterColumn("dbo.Course", "ProviderID", c => c.Int(nullable: false));
            AlterColumn("dbo.Payment", "CourseID", c => c.Int(nullable: false));
            AlterColumn("dbo.Payment", "PaymentOption", c => c.String());
            AlterColumn("dbo.Payment", "Duration", c => c.Decimal(precision: 18, scale: 2));
            AlterColumn("dbo.Payment", "Price", c => c.Decimal(nullable: false, precision: 18, scale: 2));
            AlterColumn("dbo.Payment", "Deposit", c => c.Decimal(precision: 18, scale: 2));
            AlterColumn("dbo.Payment", "AdditionalInfo", c => c.String());
            AlterColumn("dbo.Payment", "TotalAmount", c => c.Decimal(nullable: false, precision: 18, scale: 2));
            AlterColumn("dbo.Payment", "ModifiedBy", c => c.String());
            AlterColumn("dbo.Payment", "ModifiedDate", c => c.DateTime());
            AlterColumn("dbo.Student", "Title", c => c.String());
            AlterColumn("dbo.Student", "FirstName", c => c.String(maxLength: 50));
            AlterColumn("dbo.Student", "LastName", c => c.String(maxLength: 50));
            AlterColumn("dbo.Student", "Phone", c => c.String());
            AlterColumn("dbo.Student", "Email", c => c.String());
            AlterColumn("dbo.Student", "Address", c => c.String(maxLength: 255));
            AlterColumn("dbo.Student", "State", c => c.String(nullable: false, maxLength: 50));
            AlterColumn("dbo.Student", "Country", c => c.String(nullable: false, maxLength: 50));
            AlterColumn("dbo.Student", "Postcode", c => c.String(maxLength: 6));
            AlterColumn("dbo.Student", "CourseId", c => c.Int());
            AlterColumn("dbo.Student", "PaymentId", c => c.Int());
            AlterColumn("dbo.Student", "StartDate", c => c.DateTime(nullable: false));
            AlterColumn("dbo.Student", "Trxn", c => c.String());
            AlterColumn("dbo.Student", "RebillCustomerID", c => c.String());
            AlterColumn("dbo.Student", "RebillId", c => c.String());
            AlterColumn("dbo.Student", "ModifiedBy", c => c.String());
            AlterColumn("dbo.Student", "ModifiedDate", c => c.DateTime());
            AlterColumn("dbo.Transaction", "TrxnError", c => c.String());
            AlterColumn("dbo.Transaction", "TrxnStatus", c => c.String());
            AlterColumn("dbo.Transaction", "TrxnNumber", c => c.String());
            AlterColumn("dbo.Transaction", "TrxnAmount", c => c.String());
            AlterColumn("dbo.Transaction", "AuthCode", c => c.String());
            AlterColumn("dbo.Transaction", "TrxnReference", c => c.String());
            AlterColumn("dbo.Transaction", "TrxnDate", c => c.String());
            AlterColumn("dbo.Transaction", "TrxnType", c => c.String());
            AlterColumn("dbo.Transaction", "TrxnDetail", c => c.String());
            AlterColumn("dbo.Transaction", "ModifiedBy", c => c.String());
            AlterColumn("dbo.Transaction", "ModifiedDate", c => c.DateTime());
            AddForeignKey("dbo.Payment", "CourseID", "dbo.Course", "ID", cascadeDelete: true);
            AddForeignKey("dbo.Student", "CourseId", "dbo.Course", "ID");
            AddForeignKey("dbo.Student", "PaymentId", "dbo.Payment", "ID");
            CreateIndex("dbo.Payment", "CourseID");
            CreateIndex("dbo.Student", "CourseId");
            CreateIndex("dbo.Student", "PaymentId");
            DropColumn("dbo.Payment", "createBy");
            DropColumn("dbo.Payment", "createDate");
            DropColumn("dbo.Student", "createBy");
            DropColumn("dbo.Student", "createDate");
            DropColumn("dbo.Transaction", "createBy");
            DropColumn("dbo.Transaction", "createDate");
        }
        
        public override void Down()
        {
            AddColumn("dbo.Transaction", "createDate", c => c.DateTime());
            AddColumn("dbo.Transaction", "createBy", c => c.String());
            AddColumn("dbo.Student", "createDate", c => c.DateTime());
            AddColumn("dbo.Student", "createBy", c => c.String());
            AddColumn("dbo.Payment", "createDate", c => c.DateTime());
            AddColumn("dbo.Payment", "createBy", c => c.String());
            DropIndex("dbo.Student", new[] { "PaymentId" });
            DropIndex("dbo.Student", new[] { "CourseId" });
            DropIndex("dbo.Payment", new[] { "CourseID" });
            DropForeignKey("dbo.Student", "PaymentId", "dbo.Payment");
            DropForeignKey("dbo.Student", "CourseId", "dbo.Course");
            DropForeignKey("dbo.Payment", "CourseID", "dbo.Course");
            AlterColumn("dbo.Transaction", "modifiedDate", c => c.DateTime());
            AlterColumn("dbo.Transaction", "modifiedBy", c => c.String());
            AlterColumn("dbo.Transaction", "trxnDetail", c => c.String());
            AlterColumn("dbo.Transaction", "trxnType", c => c.String());
            AlterColumn("dbo.Transaction", "trxnDate", c => c.String());
            AlterColumn("dbo.Transaction", "trxnReference", c => c.String());
            AlterColumn("dbo.Transaction", "authCode", c => c.String());
            AlterColumn("dbo.Transaction", "trxnAmount", c => c.String());
            AlterColumn("dbo.Transaction", "trxnNumber", c => c.String());
            AlterColumn("dbo.Transaction", "trxnStatus", c => c.String());
            AlterColumn("dbo.Transaction", "trxnError", c => c.String());
            AlterColumn("dbo.Student", "modifiedDate", c => c.DateTime());
            AlterColumn("dbo.Student", "modifiedBy", c => c.String());
            AlterColumn("dbo.Student", "rebillId", c => c.String());
            AlterColumn("dbo.Student", "rebillCustomerID", c => c.String());
            AlterColumn("dbo.Student", "trxn", c => c.String());
            AlterColumn("dbo.Student", "startDate", c => c.DateTime(nullable: false));
            AlterColumn("dbo.Student", "paymentId", c => c.Int(nullable: false));
            AlterColumn("dbo.Student", "courseId", c => c.Int(nullable: false));
            AlterColumn("dbo.Student", "postcode", c => c.String(maxLength: 6));
            AlterColumn("dbo.Student", "country", c => c.String(nullable: false, maxLength: 50));
            AlterColumn("dbo.Student", "state", c => c.String(nullable: false, maxLength: 50));
            AlterColumn("dbo.Student", "address", c => c.String(maxLength: 255));
            AlterColumn("dbo.Student", "email", c => c.String());
            AlterColumn("dbo.Student", "phone", c => c.String());
            AlterColumn("dbo.Student", "lastName", c => c.String(maxLength: 50));
            AlterColumn("dbo.Student", "firstName", c => c.String(maxLength: 50));
            AlterColumn("dbo.Student", "title", c => c.String());
            AlterColumn("dbo.Payment", "modifiedDate", c => c.DateTime());
            AlterColumn("dbo.Payment", "modifiedBy", c => c.String());
            AlterColumn("dbo.Payment", "totalAmount", c => c.Decimal(nullable: false, precision: 18, scale: 2));
            AlterColumn("dbo.Payment", "additionalInfo", c => c.String());
            AlterColumn("dbo.Payment", "deposit", c => c.Decimal(precision: 18, scale: 2));
            AlterColumn("dbo.Payment", "price", c => c.Decimal(nullable: false, precision: 18, scale: 2));
            AlterColumn("dbo.Payment", "duration", c => c.Decimal(precision: 18, scale: 2));
            AlterColumn("dbo.Payment", "paymentOption", c => c.String());
            AlterColumn("dbo.Payment", "courseID", c => c.Int(nullable: false));
            AlterColumn("dbo.Course", "ProviderID", c => c.Int());
            DropColumn("dbo.Transaction", "CreatedDate");
            DropColumn("dbo.Transaction", "CreatedBy");
            DropColumn("dbo.Student", "CreatedDate");
            DropColumn("dbo.Student", "CreatedBy");
            DropColumn("dbo.Payment", "CreatedDate");
            DropColumn("dbo.Payment", "CreatedBy");
            CreateIndex("dbo.Student", "paymentId");
            CreateIndex("dbo.Student", "courseId");
            CreateIndex("dbo.Payment", "courseID");
            AddForeignKey("dbo.Student", "paymentId", "dbo.Payment", "ID", cascadeDelete: true);
            AddForeignKey("dbo.Student", "courseId", "dbo.Course", "ID", cascadeDelete: true);
            AddForeignKey("dbo.Payment", "courseID", "dbo.Course", "ID", cascadeDelete: true);
        }
    }
}
